home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PASCAL / 0391B.ZIP / KEYDEFS.ARC / KEYDEFS.INC next >
Text File  |  1986-03-11  |  5KB  |  111 lines

  1. (*****************************************************************************
  2. *                                                                            *
  3. *  Program:  Keydefs.Inc                                                     *
  4. *                                                                            *
  5. *   Author:  Richard R. Rebouche                                             *
  6. *                                                                            *
  7. *   Update:  03/10/86                                                        *
  8. *                                                                            *
  9. *  Purpose:  This module will allow a Turbo Pascal programmer to read        *
  10. *            extended scan codes from the keyboard and to refer to special   *
  11. *            keys (like Control_F1) by using mnemonics (like Ctrl_F1).       *
  12. *                                                                            *
  13. *    Usage:  Include this file at the beginning of your program using the    *
  14. *            dollar-include compiler directive.  {$I KeyDefs.Inc}            *
  15. *                                                                            *
  16. *            Use the function GetKey to read a keystroke from the keyboard.  *
  17. *            GetKey returns an INTEGER value.  If the value returned is      *
  18. *            less than 256, the key was a character, otherwise, it is a      *
  19. *            special key.                                                    *
  20. *                                                                            *
  21. *            The symbols (F1, Ctrl_F10, etc.) may be used in comparisons     *
  22. *            or assignments just like any other numeric constants.           *
  23. *                                                                            *
  24. *****************************************************************************)
  25.  
  26. Const  { Keyboard numeric equivalents }
  27.  
  28.        {*** Function Keys:  Alone, with Shift, Control, & Alternate keys ***}
  29.  
  30.        F1  = $1B3B;   Shft_F1  = $1B54;   Ctrl_F1  = $1B5E;   Alt_F1  = $1B68;
  31.        F2  = $1B3C;   Shft_F2  = $1B55;   Ctrl_F2  = $1B5F;   Alt_F2  = $1B69;
  32.        F3  = $1B3D;   Shft_F3  = $1B56;   Ctrl_F3  = $1B60;   Alt_F3  = $1B6A;
  33.        F4  = $1B3E;   Shft_F4  = $1B57;   Ctrl_F4  = $1B61;   Alt_F4  = $1B6B;
  34.        F5  = $1B3F;   Shft_F5  = $1B58;   Ctrl_F5  = $1B62;   Alt_F5  = $1B6C;
  35.        F6  = $1B40;   Shft_F6  = $1B59;   Ctrl_F6  = $1B63;   Alt_F6  = $1B6D;
  36.        F7  = $1B41;   Shft_F7  = $1B5A;   Ctrl_F7  = $1B64;   Alt_F7  = $1B6E;
  37.        F8  = $1B42;   Shft_F8  = $1B5B;   Ctrl_F8  = $1B65;   Alt_F8  = $1B6F;
  38.        F9  = $1B43;   Shft_F9  = $1B5C;   Ctrl_F9  = $1B66;   Alt_F9  = $1B70;
  39.        F10 = $1B44;   Shft_F10 = $1B5D;   Ctrl_F10 = $1B67;   Alt_F10 = $1B71;
  40.  
  41.  
  42.        {*** Alphanumerics:  With Alternate key ***}
  43.  
  44.        Alt_1 = $1B78;    Alt_Q = $1B10;    Alt_A = $1B1E;    Alt_Z = $1B2C;
  45.        Alt_2 = $1B79;    Alt_W = $1B11;    Alt_S = $1B1F;    Alt_X = $1B2D;
  46.        Alt_3 = $1B7A;    Alt_E = $1B12;    Alt_D = $1B20;    Alt_C = $1B2E;
  47.        Alt_4 = $1B7B;    Alt_R = $1B13;    Alt_F = $1B21;    Alt_V = $1B2F;
  48.        Alt_5 = $1B7C;    Alt_T = $1B14;    Alt_G = $1B22;    Alt_B = $1B30;
  49.        Alt_6 = $1B7D;    Alt_Y = $1B15;    Alt_H = $1B23;    Alt_N = $1B31;
  50.        Alt_7 = $1B7E;    Alt_U = $1B16;    Alt_J = $1B24;    Alt_M = $1B32;
  51.        Alt_8 = $1B7F;    Alt_I = $1B17;    Alt_K = $1B25;
  52.        Alt_9 = $1B80;    Alt_O = $1B18;    Alt_L = $1B26;
  53.        Alt_0 = $1B81;    Alt_P = $1B19;
  54.  
  55.        Alt_Minus = $1B82;
  56.        Alt_Equal = $1B83;
  57.  
  58.  
  59.        {*** Cursor Keypad:  Alone & with Control key ***}
  60.  
  61.        Home_Key   = $1B47;    Ctrl_Home  = $1B77;
  62.        End_Key    = $1B4F;    Ctrl_End   = $1B75;
  63.        PgUp       = $1B49;    Ctrl_PgUp  = $1B84;
  64.        PgDn       = $1B51;    Ctrl_PgDn  = $1B76;
  65.        Up_Key     = $1B48;  { Ctrl_Up is not returned by BIOS }
  66.        Down_Key   = $1B50;  { Ctrl_Dn is not returned by BIOS }
  67.        Left_Key   = $1B4B;    Ctrl_Left  = $1B73;
  68.        Right_Key  = $1B4D;    Ctrl_Right = $1B74;
  69.  
  70.  
  71.        {*** Miscellaneous Special Keys ***}
  72.  
  73.        Esc_Key    = $001B;
  74.        Tab_Key    = $0009;    Shft_Tab   = $1B0F;
  75.        Back_Del   = $0008;
  76.        Return     = $000D;
  77.        Space      = $0020;
  78.        Ins_Key    = $1B52;
  79.        Del_Key    = $1B53;
  80.  
  81.  
  82.  
  83. { Function:  Wait for a keystroke, return it as an integer value.  `Special' }
  84. {            keys are returned as 27 * 256 + Scan Code.                      }
  85.  
  86. Function GetKey : Integer;
  87.  
  88. Var C : Char;
  89.     I : Integer;
  90.     A : Array [0..1] of Char Absolute I;
  91.  
  92. Begin
  93.   I :=  0;
  94.   C := #0;
  95.   Read (Kbd, C);
  96.   If (C = #27) And Keypressed then
  97.     Begin
  98.       A[1] := C;
  99.       Read (Kbd, C);
  100.     End;
  101.   A[0]   := C;
  102.   GetKey := I;
  103. End;
  104.  
  105. {*** End of Key definition include file ***}
  106.  
  107.  
  108.  
  109.  
  110.  
  111.